/*
 * @lc app=leetcode id=118 lang=cpp
 *
 * [118] Pascal's Triangle
 */
class Solution {
public:
    vector<vector<int>> generate(int numRows) {
        vector<vector<int>>  ret;   
        if (numRows < 1) {
            return ret;
        }

        ret.push_back({1});
        for (int i=1; i<numRows; i++) {
            vector<int> lv(i+1, 0);
            lv[0]=1;
            for (int j=1; j<i; j++) {
                auto& prevL = ret[i-1];
                lv[j] = prevL[j-1] + prevL[j];
            }
            lv[i]=1;
            ret.push_back(lv);
        }

        return ret;
    }
};

